import { Component, Input, OnInit } from '@angular/core';

import { BaseDirective } from '../../../../core/models/base-directive.model';
import { PanelOption } from '../shared/models/panel-option.model';

declare const $: any;

@Component({
    selector: 'op-panel',
    templateUrl: './material-panel.component.html'
})
export class MaterialPanelComponent extends BaseDirective implements OnInit {
    @Input() panelOption: PanelOption;
    panelBodyId: string;
    panelFont: string;

    constructor() {
        super();
    }

    ngOnInit(): void {
        super.ngOnInit();

        this.panelBodyId = this.generatePanelBodyId('panelBodyId');
    }

    // 解决 material tab 切换时 处于隐藏的 panel 打开的问题
    hidingPanelBody(): void {
        $(`#${this.panelBodyId}`).parent().parent().attr("style", "height: 0px; visibility: hidden;");
    }

    openPanelHeader(event: boolean): void { }

    private generatePanelBodyId(identifier: string): string {
        return `${identifier}-${this.commonService.getCurrentTimestamp()}-${this.commonService.getRandomNumberWithinRange(100000, 999999)}`;
    }
}